﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Movie.web
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            string pwd = TextBox2.Text;

            Modal.User user = BLL.LoginBLL.GetUser(name);

            if (user != null)
            {
                if (user.Cpwd == pwd)
                {
                    //存入Session
                    Session["UserInfo"] = user;
                    //密码正确
                    Response.Write("<script>alert('登录成功！');</script>");
                    Response.Redirect("~/MovieInfo.aspx");
                }
                else
                {
                    Response.Write("<script>alert('密码输入错误！');</script>");
                }
            }
            else 
            {
                Response.Write("<script>alert('用户名输入错误！');</script>");
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/BeforLogin.aspx");
        }
    }
}